//
//  navSelectView.m
//  XYMaterial
//
//  Created by 肖扬 on 15/12/19.
//  Copyright © 2015年 肖扬. All rights reserved.
//

#import "navSelectView.h"
#import "varietiesView.h"
#import "brandView.h"
#import "supplyLandView.h"
#import "getCommonDataMode.h"
@implementation navSelectView
@synthesize viewData;
-(id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.viewData = [NSMutableDictionary dictionary];
        NSString *result = GETFILE(@"getcommondata.txt");
        getCommonDataMode *model = [[getCommonDataMode alloc]init];
        [model parseResponseData:result];
        self.viewData = model.data;
//        NSArray *arr = [NSArray arrayWithObjects:@"品种",@"品牌",@"货源地", nil];
//        for (int i = 0; i < [arr count]; i++) {
//            UIButton *button = [self createNavButton:CGRectMake((SWIDTH /3)*i, 0, SWIDTH/3, 44) title:[arr objectAtIndex:i] Tag:10+i];
//            [self addSubview:button];
//        }
//        UIView *line = [self createViewFrame:CGRectMake(0, 108, SWIDTH, 1) bgColor:UIColorFromRGB(0xe8e8e8) tag:0];
//        [self addSubview:line];
    }
    return self;
}
//-(UIButton *)createNavButton:(CGRect)frame
//                       title:(NSString *)title
//                         Tag:(NSInteger)tag{
//    UIButton *button = [self createButtonFrame:frame title:nil viewController:self selector:@selector(buttonClick:) tag:tag];
//    UIImageView *imageView = [self createImageViewFrame:CGRectMake(frame.size.width - 12, (frame.size.height - 5)/2, 7, 5) image:nil imageName:@"品种" tag:0];
//    [button addSubview:imageView];
//    UILabel *lab = [self createLabelFrame:CGRectMake(0, 0, frame.size.width, frame.size.height) title:title titleColor:UIColorFromRGB(0xb4b4b4) tag:0];
//    lab.textAlignment = NSTextAlignmentCenter;
//    [button addSubview:lab];
//    return button;
//}
//-(void)buttonClick:(UIButton *)sender{
//    //TODO: 按钮点击选择事件
//    if (sender.tag == 10) {
//        // 品种
//        varietiesView *varietiesV = [[varietiesView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
//        varietiesV.mainData = [self.viewData objectForKey:@"materials"];
//        [varietiesV reloadView];
//    }else if (sender.tag == 11){
//        // 品牌
//        brandView *brandV = [[brandView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
//        brandV.mainData = [self.viewData objectForKey:@"brands"];
//        brandV.tjData = [self.viewData objectForKey:@"tj_brands"];
//        
//    }else if (sender.tag == 12){
//        // 货源地
//        supplyLandView *supplyV = [[supplyLandView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
////        supplyV.mainData = [self.viewData objectForKey:@""]
//    }
//}
////创建View tag值为五位数
//- (UIView *)createViewFrame:(CGRect)frame
//                    bgColor:(UIColor *)color
//                        tag:(NSInteger)tag{
//    UIView *tempView = [[UIView alloc]initWithFrame:frame];
//    [tempView setBackgroundColor:color];
//    [tempView setTag:tag];
//    return tempView;
//}
////创建UILabel  tag值为三位数
//- (UILabel *)createLabelFrame:(CGRect)frame
//                        title:(NSString *)title
//                   titleColor:(UIColor *)color
//                          tag:(NSInteger)tag{
//    UILabel *tempLabel = [[UILabel alloc]initWithFrame:frame];
//    [tempLabel setBackgroundColor:[UIColor clearColor]];
//    [tempLabel setText:title];
//    [tempLabel setTag:tag];
//    [tempLabel setTextColor:color];
//    return tempLabel;
//}
////创建UIButton tag值为四位数
//- (UIButton *)createButtonFrame:(CGRect)frame
//                          title:(NSString *)title
//                 viewController:(id)viewController
//                       selector:(SEL)selector
//                            tag:(NSInteger)tag{
//    UIButton *tempButton = [UIButton buttonWithType:0];
//    [tempButton setFrame:frame];
//    [tempButton setTag:tag];
//    [tempButton setBackgroundColor:[UIColor clearColor]];
//    [tempButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [tempButton setTitle:title forState:UIControlStateNormal];
//    [tempButton addTarget:viewController action:selector forControlEvents:UIControlEventTouchUpInside];
//    return tempButton;
//}
////创建UIImageView tag值为五位数
//- (UIImageView *)createImageViewFrame:(CGRect)frame
//                                image:(UIImage *)image
//                            imageName:(NSString *)imageName
//                                  tag:(NSInteger)tag{
//    UIImageView *tempImageView = [[UIImageView alloc]initWithFrame:frame];
//    [tempImageView setBackgroundColor:[UIColor clearColor]];
//    if (image) {
//        tempImageView.image = image;
//    }else{
//        tempImageView.image = [UIImage imageNamed:imageName];
//    }
//    [tempImageView setTag:tag];
//    return tempImageView;
//}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
